import { expect } from 'chai';
import { getSuggestion } from '../../../src/core/utils/getSuggestion';
import { WALLET_SUGGESTION_ALL_ACTIONS, WalletSuggestionAction } from '@universal-login/commons';
describe('getSuggestion', function () {
    it('Creation', function () {
        expect(getSuggestion({ creations: ['user.mylogin.eth'], connections: [] }, WALLET_SUGGESTION_ALL_ACTIONS, 'user'))
            .be.deep.eq({ kind: 'Creation', name: 'user.mylogin.eth' });
        expect(getSuggestion({ creations: ['user.mylogin.eth'], connections: ['user.mylogin2.eth'] }, [WalletSuggestionAction.create], 'user'))
            .be.deep.eq({ kind: 'Creation', name: 'user.mylogin.eth' });
        expect(getSuggestion({ creations: ['user.mylogin.eth'], connections: [] }, [WalletSuggestionAction.create], 'user'))
            .be.deep.eq({ kind: 'Creation', name: 'user.mylogin.eth' });
    });
    it('Connection', function () {
        expect(getSuggestion({ creations: [], connections: ['user.mylogin.eth'] }, WALLET_SUGGESTION_ALL_ACTIONS, 'user'))
            .be.deep.eq({ kind: 'Connection', name: 'user.mylogin.eth' });
        expect(getSuggestion({ creations: ['user.mylogin2.eth'], connections: ['user.mylogin.eth'] }, [WalletSuggestionAction.connect], 'user'))
            .be.deep.eq({ kind: 'Connection', name: 'user.mylogin.eth' });
        expect(getSuggestion({ creations: [], connections: ['user.mylogin.eth'] }, [WalletSuggestionAction.connect], 'user'))
            .be.deep.eq({ kind: 'Connection', name: 'user.mylogin.eth' });
    });
    describe('Available', function () {
        it('2 creations, no connections', function () {
            expect(getSuggestion({ creations: ['user.mylogin.eth', 'user.mylogin2.eth'], connections: [] }, WALLET_SUGGESTION_ALL_ACTIONS, 'user'))
                .be.deep.eq({ kind: 'Available', suggestions: [{ kind: 'Creation', name: 'user.mylogin.eth' }, { kind: 'Creation', name: 'user.mylogin2.eth' }] });
        });
        it('no creations, 2 connections', function () {
            expect(getSuggestion({ creations: [], connections: ['user.mylogin.eth', 'user.mylogin2.eth'] }, WALLET_SUGGESTION_ALL_ACTIONS, 'user'))
                .be.deep.eq({ kind: 'Available', suggestions: [{ kind: 'Connection', name: 'user.mylogin.eth' }, { kind: 'Connection', name: 'user.mylogin2.eth' }] });
        });
        it('Connection and creation', function () {
            expect(getSuggestion({ creations: ['user.mylogin.eth'], connections: ['user.mylogin2.eth'] }, WALLET_SUGGESTION_ALL_ACTIONS, 'user'))
                .be.deep.eq({ kind: 'Available', suggestions: [{ kind: 'Creation', name: 'user.mylogin.eth' }, { kind: 'Connection', name: 'user.mylogin2.eth' }] });
        });
    });
    describe('TakenOrInvalid', function () {
        it('empty connections, empty creations, create action', function () {
            expect(getSuggestion({ creations: [], connections: [] }, [WalletSuggestionAction.create], 'user'))
                .be.deep.eq({ kind: 'TakenOrInvalid' });
        });
        it('non-empty connections, empty creations, create action', function () {
            expect(getSuggestion({ creations: [], connections: ['user.mylogin.eth'] }, [WalletSuggestionAction.create], 'user'))
                .be.deep.eq({ kind: 'TakenOrInvalid' });
        });
    });
    describe('isInvalidForConnection', function () {
        it('empty connections, empty creations, invalid name', function () {
            expect(getSuggestion({ creations: [], connections: [] }, [WalletSuggestionAction.connect], 'user'))
                .be.deep.eq({ kind: 'InvalidForConnection' });
        });
        it('non-empty connections, empty creations, invalid name', function () {
            expect(getSuggestion({ creations: ['user.mylogin.eth'], connections: [] }, [WalletSuggestionAction.connect], 'user'))
                .be.deep.eq({ kind: 'InvalidForConnection' });
        });
    });
    describe('KeepTyping', function () {
        var shortEnsName = 'us';
        it('empty connections, empty creations', function () {
            expect(getSuggestion({ creations: [], connections: [] }, WALLET_SUGGESTION_ALL_ACTIONS, shortEnsName))
                .be.deep.eq({ kind: 'KeepTyping' });
        });
        it('non-empty connections, empty creations', function () {
            expect(getSuggestion({ creations: [], connections: ['us.mylogin.eth'] }, WALLET_SUGGESTION_ALL_ACTIONS, shortEnsName))
                .be.deep.eq({ kind: 'KeepTyping' });
        });
        it('empty connections, non-empty creations', function () {
            expect(getSuggestion({ creations: ['us.mylogin.eth'], connections: [] }, WALLET_SUGGESTION_ALL_ACTIONS, shortEnsName))
                .be.deep.eq({ kind: 'KeepTyping' });
        });
    });
    describe('None', function () {
        var emptyEnsName = '';
        it('empty connections, empty creations', function () {
            expect(getSuggestion({ creations: [], connections: [] }, WALLET_SUGGESTION_ALL_ACTIONS, emptyEnsName))
                .be.deep.eq({ kind: 'None' });
        });
        it('non-empty connections, empty creations', function () {
            expect(getSuggestion({ creations: [], connections: ['.mylogin.eth'] }, WALLET_SUGGESTION_ALL_ACTIONS, emptyEnsName))
                .be.deep.eq({ kind: 'None' });
        });
        it('empty connections, non-empty creations', function () {
            expect(getSuggestion({ creations: ['.mylogin.eth'], connections: [] }, WALLET_SUGGESTION_ALL_ACTIONS, emptyEnsName))
                .be.deep.eq({ kind: 'None' });
            expect(getSuggestion({ creations: ['.mylogin.eth'], connections: [] }, [WalletSuggestionAction.create], emptyEnsName))
                .be.deep.eq({ kind: 'None' });
            expect(getSuggestion({ creations: ['.mylogin.eth'], connections: [] }, [WalletSuggestionAction.connect], emptyEnsName))
                .be.deep.eq({ kind: 'None' });
        });
        it('empty connections, empty creations', function () {
            expect(getSuggestion({ creations: [], connections: [] }, WALLET_SUGGESTION_ALL_ACTIONS, 'user'))
                .be.deep.eq({ kind: 'None' });
        });
        it('single creation without creation action', function () {
            expect(getSuggestion({ creations: ['user.mylogin.eth'], connections: [] }, [], 'user'))
                .be.deep.eq({ kind: 'None' });
        });
        it('single connection with empty action', function () {
            expect(getSuggestion({ creations: [], connections: ['user.mylogin.eth'] }, [], 'user'))
                .be.deep.eq({ kind: 'None' });
        });
    });
});
//# sourceMappingURL=getSuggestion.test.js.map