Skip to content

Commit

Permalink
feat: increased test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
vickywane committed Mar 4, 2021
1 parent d2e0c5c commit 0d8b090
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 41 deletions.
2 changes: 1 addition & 1 deletion src/auth/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const useAuth0 = ({
loading: true,
isAuthenticated: false,
user: {},
auth0Client: null,
auth0Client: null
}
},
methods: {
Expand Down
2 changes: 1 addition & 1 deletion src/components/authBarMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export default {
isAuthenticated: false,
showSubscription: false,
stripeId: null,
text: "Something here",
text: 'Something here',
isSubscribed: false,
showAuthenticationModal: false
}),
Expand Down
76 changes: 37 additions & 39 deletions tests/unit/integrations/auth0-wrapper.spec.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import Vue from "vue";
import { mount, createLocalVue } from "@vue/test-utils";
import Vuetify from "vuetify";
import VueX from "vuex";
import VueRouter from "vue-router";
import { Auth0Plugin } from "@/auth";

import Vue from 'vue'
import { mount, createLocalVue } from '@vue/test-utils'
import Vuetify from 'vuetify'
import VueX from 'vuex'
import VueRouter from 'vue-router'
import { Auth0Plugin } from '@/auth'

const Component = {
template: `
Expand All @@ -13,18 +12,18 @@ const Component = {
<span id="loading">{{ $auth.loading }}</span>
<span id="user">{{ $auth.user }}</span>
</div>
`,
`
}

describe("AuthBarMenu", () => {
describe('AuthBarMenu', () => {
// global
let wrapper;
const localVue = createLocalVue();
Vue.use(Vuetify); // for shallowshallowMount use
localVue.use(VueX);
let wrapper
const localVue = createLocalVue()
Vue.use(Vuetify) // for shallowshallowMount use
localVue.use(VueX)

const CLIENTDOMAIN = process.env.VUE_APP_AUTH0_DOMAIN;
const CLIENTSECRET = process.env.VUE_APP_AUTH0_CLIENTID;
const CLIENTDOMAIN = process.env.VUE_APP_AUTH0_DOMAIN
const CLIENTSECRET = process.env.VUE_APP_AUTH0_CLIENTID

// AUTH0 PLUGIN
Vue.use(Auth0Plugin, {
Expand All @@ -35,48 +34,47 @@ describe("AuthBarMenu", () => {
appState && appState.targetUrl
? appState.targetUrl
: window.location.pathname
);
},
});
)
}
})

let store, state, getters;
let store, state, getters

// global
localVue.use(VueRouter);
localVue.use(VueRouter)

const vuetify = new Vuetify();
const router = new VueRouter();
const vuetify = new Vuetify()
const router = new VueRouter()

beforeEach(() => {
state = {
pnp: {
peerConnectionStatus: jest.fn(),
},
};
peerConnectionStatus: jest.fn()
}
}

store = new VueX.Store({
state,
getters,
});
getters
})

// using shallowMount with subtree components
wrapper = mount(Component, {
localVue,
vuetify,
router,
store,
});
});
store
})
})

afterEach(() => {
wrapper.destroy();
});

wrapper.destroy()
})

// find a way to convert to BOOL values
test("It should have initial authentication & user state", () => {
expect(wrapper.find("#authenticated").text()).toBe("false");
expect(wrapper.find("#loading").text()).toBe("true");
expect(wrapper.find("#user").text()).toBe("{}");
});
});
test('It should have initial authentication & user state', () => {
expect(wrapper.find('#authenticated').text()).toBe('false')
expect(wrapper.find('#loading').text()).toBe('true')
expect(wrapper.find('#user').text()).toBe('{}')
})
})

0 comments on commit 0d8b090

Please sign in to comment.