+
+ const initialAuthState = {
+ localCluster: "zzzzz",
+ remoteHostsConfig: {},
+ sessions: {},
+ };
+
+ store = createStore(combineReducers({
+ auth: (state: any = initialAuthState, action: any) => state,
+ }));
+ });
+
+ describe('Get API Token dialog', () => {
+ beforeEach(() => {
+ wrapper = mount(
+ <Provider store={store}>
+ <TokenDialogComponent {...props} />
+ </Provider>
+ );
+ });
+
+ it('should include API host and token', () => {
+ expect(wrapper.html()).toContain('export ARVADOS_API_HOST=example.com');
+ expect(wrapper.html()).toContain('export ARVADOS_API_TOKEN=xxxtokenxxx');
+ });
+
+ it('should show the token expiration if present', () => {
+ expect(props.tokenExpiration).toBeUndefined();
+ expect(wrapper.html()).toContain('This token does not have an expiration date');
+
+ const someDate = '2140-01-01T00:00:00.000Z'
+ props.tokenExpiration = new Date(someDate);
+ wrapper = mount(
+ <Provider store={store}>
+ <TokenDialogComponent {...props} />
+ </Provider>);
+ expect(wrapper.html()).toContain(props.tokenExpiration.toLocaleString());
+ });
+
+ it('should show a create new token button when allowed', () => {
+ expect(props.canCreateNewTokens).toBeFalsy();
+ expect(wrapper.html()).not.toContain('GET NEW TOKEN');
+
+ props.canCreateNewTokens = true;
+ wrapper = mount(
+ <Provider store={store}>
+ <TokenDialogComponent {...props} />
+ </Provider>);
+ expect(wrapper.html()).toContain('GET NEW TOKEN');
+ });