123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- suite('lunr.Set', function () {
- suite('#contains', function () {
- suite('complete set', function () {
- test('returns true', function () {
- assert.isOk(lunr.Set.complete.contains('foo'))
- })
- })
- suite('empty set', function () {
- test('returns false', function () {
- assert.isNotOk(lunr.Set.empty.contains('foo'))
- })
- })
- suite('populated set', function () {
- setup(function () {
- this.set = new lunr.Set (['foo'])
- })
- test('element contained in set', function () {
- assert.isOk(this.set.contains('foo'))
- })
- test('element not contained in set', function () {
- assert.isNotOk(this.set.contains('bar'))
- })
- })
- })
- suite('#union', function () {
- setup(function () {
- this.set = new lunr.Set(['foo'])
- })
- suite('complete set', function () {
- test('union is complete', function () {
- var result = lunr.Set.complete.union(this.set)
- assert.isOk(result.contains('foo'))
- assert.isOk(result.contains('bar'))
- })
- })
- suite('empty set', function () {
- test('contains element', function () {
- var result = lunr.Set.empty.union(this.set)
- assert.isOk(result.contains('foo'))
- assert.isNotOk(result.contains('bar'))
- })
- })
- suite('populated set', function () {
- suite('with other populated set', function () {
- test('contains both elements', function () {
- var target = new lunr.Set (['bar'])
- var result = target.union(this.set)
- assert.isOk(result.contains('foo'))
- assert.isOk(result.contains('bar'))
- assert.isNotOk(result.contains('baz'))
- })
- })
- suite('with empty set', function () {
- test('contains all elements', function () {
- var target = new lunr.Set (['bar'])
- var result = target.union(lunr.Set.empty)
- assert.isOk(result.contains('bar'))
- assert.isNotOk(result.contains('baz'))
- })
- })
- suite('with complete set', function () {
- test('contains all elements', function () {
- var target = new lunr.Set (['bar'])
- var result = target.union(lunr.Set.complete)
- assert.isOk(result.contains('foo'))
- assert.isOk(result.contains('bar'))
- assert.isOk(result.contains('baz'))
- })
- })
- })
- })
- suite('#intersect', function () {
- setup(function () {
- this.set = new lunr.Set(['foo'])
- })
- suite('complete set', function () {
- test('contains element', function () {
- var result = lunr.Set.complete.intersect(this.set)
- assert.isOk(result.contains('foo'))
- assert.isNotOk(result.contains('bar'))
- })
- })
- suite('empty set', function () {
- test('does not contain element', function () {
- var result = lunr.Set.empty.intersect(this.set)
- assert.isNotOk(result.contains('foo'))
- })
- })
- suite('populated set', function () {
- suite('no intersection', function () {
- test('does not contain intersection elements', function () {
- var target = new lunr.Set (['bar'])
- var result = target.intersect(this.set)
- assert.isNotOk(result.contains('foo'))
- assert.isNotOk(result.contains('bar'))
- })
- })
- suite('intersection', function () {
- test('contains intersection elements', function () {
- var target = new lunr.Set (['foo', 'bar'])
- var result = target.intersect(this.set)
- assert.isOk(result.contains('foo'))
- assert.isNotOk(result.contains('bar'))
- })
- })
- suite('with empty set', function () {
- test('returns empty set', function () {
- var target = new lunr.Set(['foo']),
- result = target.intersect(lunr.Set.empty)
- assert.isNotOk(result.contains('foo'))
- })
- })
- suite('with complete set', function () {
- test('returns populated set', function () {
- var target = new lunr.Set(['foo']),
- result = target.intersect(lunr.Set.complete)
- assert.isOk(result.contains('foo'))
- assert.isNotOk(result.contains('bar'))
- })
- })
- })
- })
- })
|