You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
689 B

4 years ago
  1. var tape = require('tape')
  2. var indexes = require('./')
  3. tape('indexes of - 2 matches', function (t) {
  4. var x = indexes([1,2,3, 2,4,5,9,8,0], 2)
  5. t.deepEqual(x, [1,3])
  6. t.end()
  7. })
  8. tape('indexes of - 1 match', function (t) {
  9. var x = indexes([1,2,3, 2,4,5,9,8,0], 2)
  10. t.deepEqual(x, [1,3])
  11. t.end()
  12. })
  13. tape('indexes of - empty', function (t) {
  14. var x = indexes([1,2,3, 2,4,5,9,8,0], 24)
  15. t.deepEqual(x, [])
  16. t.end()
  17. })
  18. tape('indexes of - empty', function (t) {
  19. var x = indexes([8,8,8,8,8,8,8], 8)
  20. t.deepEqual(x, [0,1,2,3,4,5,6])
  21. t.end()
  22. })
  23. tape('indexes of - string', function (t) {
  24. var x = indexes('foo bar baz foo', 'foo')
  25. t.deepEqual(x, [0, 12])
  26. t.end()
  27. })