Created
October 24, 2019 11:48
-
-
Save MatthewTrout/fd53e8331414b01e723bffade6049a50 to your computer and use it in GitHub Desktop.
es6 flatten test
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
import { flatten } from "./flatten"; | |
test('flatten works', () => { | |
expect( | |
flatten( | |
[1, 2, [3, 4, 5], 6, [7], 8, 9, 10] | |
) | |
).toEqual( | |
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10] | |
); | |
}); | |
test('flatten works with multiple levels of nested arrays', () => { | |
expect( | |
flatten( | |
[1, 2, [3, 4, 5], 6, [7, [8, [9]], 10]] | |
) | |
).toEqual( | |
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10] | |
); | |
}); | |
test('flatten works with no nesting', () => { | |
expect( | |
flatten( | |
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10] | |
) | |
).toEqual( | |
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10] | |
); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment