-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f103ed9
commit 30e3c76
Showing
4 changed files
with
87 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
src/collections/tests/ObservableCollection/ObservableCollection.join.tests.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { ObservableCollection } from '../../ObservableCollection'; | ||
import { testBlankMutatingOperation } from './common'; | ||
|
||
describe('ObserableCollection.join', (): void => { | ||
it('joining an empty collection returns an empty string', (): void => { | ||
testBlankMutatingOperation<number>({ | ||
initialState: [], | ||
|
||
applyOperation: collection => collection.join() | ||
}); | ||
}); | ||
|
||
it('joining an empty collection with separator returns an empty string', (): void => { | ||
testBlankMutatingOperation<number>({ | ||
initialState: [], | ||
|
||
applyOperation: collection => collection.join('-') | ||
}); | ||
}); | ||
|
||
it('joining a collection returns a string containing the string representations of each element in one string separated by comma', (): void => { | ||
testBlankMutatingOperation<unknown>({ | ||
initialState: [null, undefined, 1, 'A', { prop: 'value' }, new Date(), ObservableCollection], | ||
|
||
applyOperation: collection => collection.join() | ||
}); | ||
}); | ||
|
||
it('joining a collection with separator returns a string containing the string representations of each element in one string separated by the separator', (): void => { | ||
testBlankMutatingOperation<unknown>({ | ||
initialState: [null, undefined, 1, 'A', { prop: 'value' }, new Date(), ObservableCollection], | ||
|
||
applyOperation: collection => collection.join('-') | ||
}); | ||
}); | ||
|
||
it('joining a collection with undefined separator returns a string containing the string representations of each element in one string separated by comma', (): void => { | ||
testBlankMutatingOperation<unknown>({ | ||
initialState: [null, undefined, 1, 'A', { prop: 'value' }, new Date(), ObservableCollection], | ||
|
||
applyOperation: collection => collection.join(undefined) | ||
}); | ||
}); | ||
|
||
it('joining a collection with null separator returns a string containing the string representations of each element in one string', (): void => { | ||
testBlankMutatingOperation<unknown>({ | ||
initialState: [null, undefined, 1, 'A', { prop: 'value' }, new Date(), ObservableCollection], | ||
|
||
applyOperation: collection => collection.join(null) | ||
}); | ||
}); | ||
|
||
it('calling join while iterating will not break iterators', (): void => { | ||
expect( | ||
() => { | ||
const observableCollection = new ObservableCollection<number>(1, 2, 3); | ||
|
||
for (const _ of observableCollection) | ||
observableCollection.join(); | ||
}) | ||
.not | ||
.toThrow(); | ||
}); | ||
}); |