import request from "supertest";
import getConfig from "../../libs/config";
import getApp from '../../app'



describe('selectAdressPageRouter', () => {
    const config = getConfig();
    config.env = "test";
    const app = getApp(config);
    const appRequest = request(app);


    test('should redirect to same with error when no value is selected', async () => {

        const response = await appRequest.post('/address-select').send({ address: '' });
        expect(response.status).toBe(302);
        expect(response.text).toContain('Found. Redirecting to /address-select?hasError=true')
    })

    test('should redirect to demo page when address  is selected', async () => {

        const response = await appRequest.post('/address-select').send({ address: '100110668168' });
        expect(response.status).toBe(302);
        expect(response.header['location']).toContain('/demo');

    })
});
