Skip to content

Commit

Permalink
Change function names
Browse files Browse the repository at this point in the history
  • Loading branch information
Azer0s committed Nov 5, 2019
1 parent 9e46bcf commit c50cc9d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 21 deletions.
9 changes: 3 additions & 6 deletions examples/tests/cypress/integration/channels.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ describe('Channels', () => {
cy.subscribe('mike', 'my.public.event');
// "foo":"bar" due to way how Cypress handles escaping of curly braces
cy.sendEvent('my.public.event', '"foo":"bar"');
cy.assertSingleNewEventContainsMessage('event-log', '(.*my.public.event)(.*"foo":"bar")');
cy.assertEventLogHasMatch('(.*my.public.event)(.*"foo":"bar")');
cy.disconnect();
});

Expand All @@ -16,14 +16,11 @@ describe('Channels', () => {
cy.subscribe('mike', 'message');
// "name":"mike","foo":"bar" due to way how Cypress handles escaping of curly braces
cy.sendEvent('message', '"name":"mike","foo":"bar"');
cy.assertSingleNewEventContainsMessage('event-log', '"name":"mike","foo":"bar"');
cy.assertEventLogHasMatch('"name":"mike","foo":"bar"');
// send constrained event for different user - John
cy.sendEvent('message', '"name":"john","foo":"bar"');
// Mike shouldn't receive any new event
cy.assertSingleNewEventContainsMessage(
'event-log',
'(.*message)(.*"name":"mike","foo":"bar")'
);
cy.assertEventLogHasMatch('(.*message)(.*"name":"mike","foo":"bar")');
cy.disconnect();
});
});
Expand Down
13 changes: 5 additions & 8 deletions examples/tests/cypress/integration/subscriptions-jwt.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,33 @@ describe('Subscriptions with JWT auth', () => {
cy.visit(`/${type}-3-demo-jwt.html`);
cy.setAndVerifyInput('greeting', 'hello');
cy.submit();
cy.assertNewestEventContainsMessage('eventList', 'hello');
cy.assertEventInEventList('hello');
});

it(`Applies ${type} subscription constraints tied with JWT for given event type`, () => {
cy.visit(`/${type}-demo-jwt-extractors.html`);
cy.setAndVerifyInput('greeting', 'hello');
cy.setAndVerifyInput('name', 'john');
cy.submit();
cy.assertNewestEventContainsMessage('eventList', '"name":"john","greeting":"hello"');
cy.assertEventInEventList('"name":"john","greeting":"hello"');
// John shouldn't receive Mike's events
cy.setAndVerifyInput('greeting', 'hello');
cy.setAndVerifyInput('name', 'mike');
cy.submit();
cy.assertNewestEventContainsMessage('eventList', '"name":"john","greeting":"hello"');
cy.assertEventInEventList('"name":"john","greeting":"hello"');
});

it(`Creates ${type} subscriptions based on JWT in connection call and applies constraints`, () => {
cy.visit(`/${type}-demo-jwt-extractors-conn.html`);
cy.setAndVerifyInput('greeting', 'hello');
cy.setAndVerifyInput('name', 'john.doe');
cy.submit();
cy.assertNewestEventContainsMessage('eventList', '"name":"john.doe","greeting":"hello"');
cy.assertEventInEventList('"name":"john.doe","greeting":"hello"');
// John Doe shouldn't receive Mike's events
cy.setAndVerifyInput('greeting', 'hello');
cy.setAndVerifyInput('name', 'mike');
cy.submit();
cy.assertNewestEventContainsMessage(
'eventList',
'"name":"john.doe","greeting":"hello"'
);
cy.assertEventInEventList('"name":"john.doe","greeting":"hello"');
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@ describe('Subscriptions with no auth', () => {
cy.visit(`/${type}-1-demo.html`);
cy.setAndVerifyInput('greeting', 'hello');
cy.submit();
cy.assertNewestEventContainsMessage('eventList', 'hello');
cy.assertEventInEventList('hello');
});

it(`Creates ${type} connection and subscriptions within a same call`, () => {
cy.visit(`/${type}-demo-single-call.html`);
cy.setAndVerifyInput('greeting', 'hello');
cy.submit();
cy.assertNewestEventContainsMessage('eventList', 'hello');
cy.assertEventInEventList('hello');
});

it(`Applies ${type} subscription constraints for given event type`, () => {
cy.visit(`/${type}-2-demo-simple-extractors.html`);
cy.setAndVerifyInput('greeting', 'hello');
cy.setAndVerifyInput('name', 'john');
cy.submit();
cy.assertNewestEventContainsMessage('eventList', '"name":"john","greeting":"hello"');
cy.assertEventInEventList('"name":"john","greeting":"hello"');
// John shouldn't receive Mike's events
cy.setAndVerifyInput('greeting', 'hello');
cy.setAndVerifyInput('name', 'mike');
cy.submit();
cy.assertNewestEventContainsMessage('eventList', '"name":"john","greeting":"hello"');
cy.assertEventInEventList('"name":"john","greeting":"hello"');
});
});
});
6 changes: 3 additions & 3 deletions examples/tests/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ Cypress.Commands.add('sendEvent', (eventType, message) => {
cy.get('#send-button').click();
});

Cypress.Commands.add('assertNewestEventContainsMessage', (element, message) => {
Cypress.Commands.add('assertEventInEventList', (message) => {
// assert number and content of received events
cy.get(`#${element} > li`, {timeout: 30000})
cy.get(`#eventList > li`, {timeout: 30000})
.should('be.visible')
.first()
.contains(message)
});

Cypress.Commands.add('assertSingleNewEventContainsMessage', (element, message) => {
Cypress.Commands.add('assertEventLogHasMatch', (message) => {
// assert number and content of received events
cy.get(`#${element}`, {timeout: 30000})
.should('have.length', 1)
Expand Down

0 comments on commit c50cc9d

Please sign in to comment.