Skip to content

Commit

Permalink
Add snapshot tests for matchers
Browse files Browse the repository at this point in the history
This enables us to refactor matchers more easily
  • Loading branch information
DanielMSchmidt committed Oct 18, 2017
1 parent 30eeefd commit 7a98196
Show file tree
Hide file tree
Showing 4 changed files with 561 additions and 0 deletions.
262 changes: 262 additions & 0 deletions detox/src/android/__snapshots__/matcher.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,262 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`android matcher invocations should remain the same 1`] = `
Object {
"args": Array [
"mySelector",
],
"method": "matcherForContentDescription",
"target": Object {
"type": "Class",
"value": "com.wix.detox.espresso.DetoxMatcher",
},
}
`;

exports[`android matcher invocations should remain the same 2`] = `
Object {
"args": Array [
"mySelector",
],
"method": "matcherForTestId",
"target": Object {
"type": "Class",
"value": "com.wix.detox.espresso.DetoxMatcher",
},
}
`;

exports[`android matcher invocations should remain the same 3`] = `
Object {
"args": Array [
"mySelector",
],
"method": "matcherForClass",
"target": Object {
"type": "Class",
"value": "com.wix.detox.espresso.DetoxMatcher",
},
}
`;

exports[`android matcher invocations should remain the same 4`] = `
Object {
"args": Array [
"mySelector",
],
"method": "matcherForText",
"target": Object {
"type": "Class",
"value": "com.wix.detox.espresso.DetoxMatcher",
},
}
`;

exports[`android matcher invocations should remain the same 5`] = `
Object {
"args": Array [
"mySelector",
],
"method": "matcherForContentDescription",
"target": Object {
"type": "Class",
"value": "com.wix.detox.espresso.DetoxMatcher",
},
}
`;

exports[`android matcher invocations should remain the same 6`] = `
Object {
"args": Array [
Object {
"type": "Invocation",
"value": Object {
"args": Array [
"mySelector",
],
"method": "matcherForContentDescription",
"target": Object {
"type": "Class",
"value": "com.wix.detox.espresso.DetoxMatcher",
},
},
},
Object {
"type": "Invocation",
"value": Object {
"args": Array [
"myOtherSelector",
],
"method": "matcherForContentDescription",
"target": Object {
"type": "Class",
"value": "com.wix.detox.espresso.DetoxMatcher",
},
},
},
],
"method": "matcherWithAncestor",
"target": Object {
"type": "Class",
"value": "com.wix.detox.espresso.DetoxMatcher",
},
}
`;

exports[`android matcher invocations should remain the same 7`] = `
Object {
"args": Array [
Object {
"type": "Invocation",
"value": Object {
"args": Array [
"mySelector",
],
"method": "matcherForContentDescription",
"target": Object {
"type": "Class",
"value": "com.wix.detox.espresso.DetoxMatcher",
},
},
},
Object {
"type": "Invocation",
"value": Object {
"args": Array [
"myOtherSelector",
],
"method": "matcherForContentDescription",
"target": Object {
"type": "Class",
"value": "com.wix.detox.espresso.DetoxMatcher",
},
},
},
],
"method": "matcherWithDescendant",
"target": Object {
"type": "Class",
"value": "com.wix.detox.espresso.DetoxMatcher",
},
}
`;

exports[`android matcher invocations should remain the same 8`] = `
Object {
"args": Array [
Object {
"type": "Invocation",
"value": Object {
"args": Array [
"mySelector",
],
"method": "matcherForContentDescription",
"target": Object {
"type": "Class",
"value": "com.wix.detox.espresso.DetoxMatcher",
},
},
},
Object {
"type": "Invocation",
"value": Object {
"args": Array [
"myOtherSelector",
],
"method": "matcherForContentDescription",
"target": Object {
"type": "Class",
"value": "com.wix.detox.espresso.DetoxMatcher",
},
},
},
],
"method": "matcherForAnd",
"target": Object {
"type": "Class",
"value": "com.wix.detox.espresso.DetoxMatcher",
},
}
`;

exports[`android matcher invocations should remain the same 9`] = `
Object {
"args": Array [
Object {
"type": "Invocation",
"value": Object {
"args": Array [
"mySelector",
],
"method": "matcherForContentDescription",
"target": Object {
"type": "Class",
"value": "com.wix.detox.espresso.DetoxMatcher",
},
},
},
Object {
"type": "Invocation",
"value": Object {
"args": Array [
"myOtherSelector",
],
"method": "matcherForContentDescription",
"target": Object {
"type": "Class",
"value": "com.wix.detox.espresso.DetoxMatcher",
},
},
},
],
"method": "matcherForOr",
"target": Object {
"type": "Class",
"value": "com.wix.detox.espresso.DetoxMatcher",
},
}
`;

exports[`android matcher invocations should remain the same 10`] = `
Object {
"args": Array [],
"method": "matcherForSufficientlyVisible",
"target": Object {
"type": "Class",
"value": "com.wix.detox.espresso.DetoxMatcher",
},
}
`;

exports[`android matcher invocations should remain the same 11`] = `
Object {
"args": Array [],
"method": "matcherForNotVisible",
"target": Object {
"type": "Class",
"value": "com.wix.detox.espresso.DetoxMatcher",
},
}
`;

exports[`android matcher invocations should remain the same 12`] = `
Object {
"args": Array [],
"method": "matcherForNotNull",
"target": Object {
"type": "Class",
"value": "com.wix.detox.espresso.DetoxMatcher",
},
}
`;

exports[`android matcher invocations should remain the same 13`] = `
Object {
"args": Array [],
"method": "matcherForNull",
"target": Object {
"type": "Class",
"value": "com.wix.detox.espresso.DetoxMatcher",
},
}
`;
25 changes: 25 additions & 0 deletions detox/src/android/matcher.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
describe('android matcher', async () => {
let m;

beforeEach(() => {
m = require('./matcher');
});

it("invocations should remain the same", () => {
const textBasedMatchers = ['LabelMatcher', 'IdMatcher', 'TypeMatcher', 'TextMatcher', 'ValueMatcher'];
const chainableMatchers = ['withAncestor', 'withDescendant', 'and', 'or'];
const noArgsMatchers = ['VisibleMatcher', 'NotVisibleMatcher', 'ExistsMatcher', 'NotExistsMatcher'];

textBasedMatchers.forEach(matcher => {
expect(new m[matcher]("mySelector")._call()).toMatchSnapshot();
});

chainableMatchers.forEach(matcher => {
expect(new m.LabelMatcher("mySelector")[matcher](new m.LabelMatcher("myOtherSelector"))._call()).toMatchSnapshot()
});

noArgsMatchers.forEach(matcher => {
expect(new m[matcher]()._call()).toMatchSnapshot();
});
});
});
Loading

0 comments on commit 7a98196

Please sign in to comment.