-
Notifications
You must be signed in to change notification settings - Fork 6
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
Showing
5 changed files
with
81 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"presets": [ | ||
"babel-preset-latest" | ||
] | ||
} |
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
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,37 @@ | ||
import test from 'ava' | ||
import { | ||
reducer, | ||
mediaChanged, | ||
mediaQueryTracker, | ||
unlisten, | ||
} from './media-query-tracker' | ||
|
||
test('reducer works', t => { | ||
t.deepEqual(reducer({}, mediaChanged({innerHeight: 123})), { | ||
innerHeight: 123, | ||
}) | ||
}) | ||
|
||
test('reducer keeps other data', t => { | ||
t.deepEqual(reducer({foo: 3}, mediaChanged({innerHeight: 123})), { | ||
foo: 3, | ||
innerHeight: 123, | ||
}) | ||
}) | ||
|
||
test('mediaQueryTracker works outside browser', t => { | ||
const dispatch = () => {} | ||
let unlisten | ||
t.notThrows(() => { | ||
unlisten = mediaQueryTracker({ | ||
isPhone: 'screen and (max-width: 767px)', | ||
}) | ||
}, dispatch) | ||
t.notThrows(unlisten) | ||
}) | ||
|
||
// TODO create redux store; mock matchmedia and addEventListener | ||
test.todo('calls matchMedia if needed') | ||
test.todo('calls addEventListener if needed') | ||
test.todo('unlisten unlistens') | ||
test.todo('mediaQueryTracker works as thunking action') |