Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add snapshot tests for matchers #347

Merged
merged 1 commit into from
Oct 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 snapshots 1`] = `
Object {
"args": Array [
"mySelector",
],
"method": "matcherForContentDescription",
"target": Object {
"type": "Class",
"value": "com.wix.detox.espresso.DetoxMatcher",
},
}
`;

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

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

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

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

exports[`android matcher snapshots 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 snapshots 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 snapshots 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 snapshots 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 snapshots 10`] = `
Object {
"args": Array [],
"method": "matcherForSufficientlyVisible",
"target": Object {
"type": "Class",
"value": "com.wix.detox.espresso.DetoxMatcher",
},
}
`;

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

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

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

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

// These snapshots preserve the output of the matchers against unwanted change
it("snapshots", () => {
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