+ )
let node
- beforeEach(function () {
+ beforeEach(() => {
node = document.createElement('div')
})
- it('should not render unnecessary class=""', function () {
+ it('should not render unnecessary class=""', () => {
render((
- ), node, function () {
+ ), node, () => {
const a = node.querySelector('a')
expect(a.hasAttribute('class')).toBe(false)
})
})
- it('knows how to make its href', function () {
- class LinkWrapper extends Component {
- render() {
- return (
-
- Link
-
- )
- }
- }
+ it('knows how to make its href', () => {
+ const LinkWrapper = () => (
+
+ Link
+
+ )
render((
- ), node, function () {
+ ), node, () => {
const a = node.querySelector('a')
expect(a.getAttribute('href')).toEqual('/hello/michael?the=query#the-hash')
})
})
- // This test needs to be in its own file with beforeEach(resetHash).
- //
- //it('knows how to make its href with HashHistory', function () {
- // class LinkWrapper extends Component {
- // render() {
- // return Link
- // }
- // }
-
- // render((
- //
- //
- //
- // ), node, function () {
- // const a = node.querySelector('a')
- // expect(a.getAttribute('href')).toEqual('#/hello/michael?the=query')
- // })
- //})
-
- describe('with params', function () {
- class App extends Component {
- render() {
- return (
-
-
- Michael
-
-
- Ryan
-
-
- )
- }
- }
+ describe('with hash history', () => {
+ it('should know how to make its href', () => {
+ const LinkWrapper = () => (
+
+ Link
+
+ )
+
+ render((
+
+
+
+ ), node, () => {
+ const a = node.querySelector('a')
+ expect(a.getAttribute('href')).toEqual('#/hello/michael?the=query')
+ })
+ })
+ })
- it('is active when its params match', function (done) {
+ describe('with params', () => {
+ const App = () => (
+
+
+ Michael
+
+
+ Ryan
+
+
+ )
+
+ it('is active when its params match', done => {
render((
- ), node, function () {
+ ), node, () => {
const a = node.querySelectorAll('a')[0]
expect(a.className.trim()).toEqual('active')
done()
})
})
- it('is not active when its params do not match', function (done) {
+ it('is not active when its params do not match', done => {
render((
- ), node, function () {
+ ), node, () => {
const a = node.querySelectorAll('a')[1]
expect(a.className.trim()).toEqual('')
done()
})
})
- it('is active when its params and query match', function (done) {
+ it('is active when its params and query match', done => {
render((
- ), node, function () {
+ ), node, () => {
const a = node.querySelectorAll('a')[1]
expect(a.className.trim()).toEqual('active')
done()
})
})
- it('is not active when its query does not match', function (done) {
+ it('is not active when its query does not match', done => {
render((
- ), node, function () {
+ ), node, () => {
const a = node.querySelectorAll('a')[1]
expect(a.className.trim()).toEqual('')
done()
@@ -161,29 +150,27 @@ describe('A ', function () {
})
})
- describe('when its route is active and className is empty', function () {
- it("it shouldn't have an active class", function (done) {
- class LinkWrapper extends Component {
- render() {
- return (
-
- Link
- {this.props.children}
-
- )
- }
- }
+ describe('when its route is active and className is empty', () => {
+ it("it shouldn't have an active class", done => {
+ const LinkWrapper = ({ children }) => (
+
+
+ Link
+
+ {children}
+
+ )
const history = createHistory('/goodbye')
let a
const steps = [
- function () {
+ () => {
a = node.querySelector('a')
expect(a.className).toEqual('dontKillMe')
history.push('/hello')
},
- function () {
+ () => {
expect(a.className).toEqual('dontKillMe')
}
]
@@ -201,28 +188,26 @@ describe('A ', function () {
})
})
- describe('when its route is active', function () {
- it('has its activeClassName', function (done) {
- class LinkWrapper extends Component {
- render() {
- return (
-
- Link
- {this.props.children}
-
- )
- }
- }
+ describe('when its route is active', () => {
+ it('has its activeClassName', done => {
+ const LinkWrapper = ({ children }) => (
+
+
+ Link
+
+ {children}
+
+ )
let a
const history = createHistory('/goodbye')
const steps = [
- function () {
+ () => {
a = node.querySelector('a')
expect(a.className).toEqual('dontKillMe')
history.push('/hello')
},
- function () {
+ () => {
expect(a.className).toEqual('dontKillMe highlight')
}
]
@@ -239,27 +224,29 @@ describe('A ', function () {
), node, execNextStep)
})
- it('has its activeStyle', function (done) {
- class LinkWrapper extends Component {
- render() {
- return (
-