/* eslint-env mocha */
import React from 'react';
import { assert } from 'chai';
import Button, { styleSheet } from './Button';
import { createShallowWithContext } from 'test/utils';

describe('<Button>', () => {
  let shallow;
  let classes;

  before(() => {
    shallow = createShallowWithContext();
    classes = shallow.context.styleManager.render(styleSheet, { group: 'mui' });
  });

  it('should render a <ButtonBase> element', () => {
    const wrapper = shallow(
      <Button>Hello World</Button>
    );
    assert.strictEqual(wrapper.is('ButtonBase'), true, 'should be a <button>');
    assert.strictEqual(wrapper.prop('type'), 'button', 'should render with the button type attribute');
  });

  it('should render with the root class but no others', () => {
    const wrapper = shallow(
      <Button>Hello World</Button>
    );
    assert.strictEqual(wrapper.hasClass(classes.root), true, 'should have the root class');
    assert.strictEqual(wrapper.hasClass(classes.raised), false, 'should not have the raised class');
    assert.strictEqual(wrapper.hasClass(classes.fab), false, 'should not have the fab class');
    assert.strictEqual(wrapper.hasClass(classes.primary), false, 'should not have the primary class');
    assert.strictEqual(wrapper.hasClass(classes.accent), false, 'should not have the accent class');
  });

  it('should render the custom className and the root class', () => {
    const wrapper = shallow(
      <Button className="test-class-name" />
    );
    assert.strictEqual(wrapper.is('.test-class-name'), true, 'should pass the test className');
    assert.strictEqual(wrapper.hasClass(classes.root), true, 'should have the root class');
  });

  it('should render a primary button', () => {
    const wrapper = shallow(
      <Button primary>Hello World</Button>
    );
    assert.strictEqual(wrapper.hasClass(classes.root), true, 'should have the root class');
    assert.strictEqual(wrapper.hasClass(classes.raised), false, 'should have the raised class');
    assert.strictEqual(wrapper.hasClass(classes.fab), false, 'should not have the fab class');
    assert.strictEqual(wrapper.hasClass(classes.primary), true, 'should not have the primary class');
    assert.strictEqual(wrapper.hasClass(classes.accent), false, 'should not have the accent class');
  });

  it('should render an accent button', () => {
    const wrapper = shallow(
      <Button accent>Hello World</Button>
    );
    assert.strictEqual(wrapper.hasClass(classes.root), true, 'should have the root class');
    assert.strictEqual(wrapper.hasClass(classes.raised), false, 'should have the raised class');
    assert.strictEqual(wrapper.hasClass(classes.fab), false, 'should not have the fab class');
    assert.strictEqual(wrapper.hasClass(classes.primary), false, 'should not have the primary class');
    assert.strictEqual(wrapper.hasClass(classes.accent), true, 'should not have the accent class');
  });

  it('should render a raised button', () => {
    const wrapper = shallow(
      <Button raised>Hello World</Button>
    );
    assert.strictEqual(wrapper.hasClass(classes.root), true, 'should have the root class');
    assert.strictEqual(wrapper.hasClass(classes.raised), true, 'should have the raised class');
    assert.strictEqual(wrapper.hasClass(classes.fab), false, 'should not have the fab class');
    assert.strictEqual(wrapper.hasClass(classes.primary), false, 'should not have the primary class');
    assert.strictEqual(wrapper.hasClass(classes.accent), false, 'should not have the accent class');
  });

  it('should render a raised primary button', () => {
    const wrapper = shallow(
      <Button raised primary>Hello World</Button>
    );
    assert.strictEqual(wrapper.hasClass(classes.root), true, 'should have the root class');
    assert.strictEqual(wrapper.hasClass(classes.raised), true, 'should have the raised class');
    assert.strictEqual(wrapper.hasClass(classes.fab), false, 'should not have the fab class');
    assert.strictEqual(wrapper.hasClass(classes.primary), true, 'should have the primary class');
    assert.strictEqual(wrapper.hasClass(classes.accent), false, 'should not have the accent class');
  });

  it('should render a raised accent button', () => {
    const wrapper = shallow(
      <Button raised accent>Hello World</Button>
    );
    assert.strictEqual(wrapper.hasClass(classes.root), true, 'should have the root class');
    assert.strictEqual(wrapper.hasClass(classes.raised), true, 'should have the raised class');
    assert.strictEqual(wrapper.hasClass(classes.fab), false, 'should not have the fab class');
    assert.strictEqual(wrapper.hasClass(classes.primary), false, 'should not have the primary class');
    assert.strictEqual(wrapper.hasClass(classes.accent), true, 'should have the accent class');
  });

  it('should render a floating action button', () => {
    const wrapper = shallow(
      <Button fab />
    );
    assert.strictEqual(wrapper.hasClass(classes.root), true, 'should have the root class');
    assert.strictEqual(wrapper.hasClass(classes.raised), true, 'should have the raised class');
    assert.strictEqual(wrapper.hasClass(classes.fab), true, 'should have the fab class');
    assert.strictEqual(wrapper.hasClass(classes.primary), false, 'should not have the primary class');
    assert.strictEqual(wrapper.hasClass(classes.accent), false, 'should not have the accent class');
  });

  it('should render a primary floating action button', () => {
    const wrapper = shallow(
      <Button fab primary />
    );
    assert.strictEqual(wrapper.hasClass(classes.root), true, 'should have the root class');
    assert.strictEqual(wrapper.hasClass(classes.raised), true, 'should have the raised class');
    assert.strictEqual(wrapper.hasClass(classes.fab), true, 'should have the fab class');
    assert.strictEqual(wrapper.hasClass(classes.primary), true, 'should have the primary class');
    assert.strictEqual(wrapper.hasClass(classes.accent), false, 'should not have the accent class');
  });

  it('should render an accent floating action button', () => {
    const wrapper = shallow(
      <Button fab accent />
    );
    assert.strictEqual(wrapper.hasClass(classes.root), true, 'should have the root class');
    assert.strictEqual(wrapper.hasClass(classes.raised), true, 'should have the raised class');
    assert.strictEqual(wrapper.hasClass(classes.fab), true, 'should have the fab class');
    assert.strictEqual(wrapper.hasClass(classes.primary), false, 'should not have the primary class');
    assert.strictEqual(wrapper.hasClass(classes.accent), true, 'should have the accent class');
  });
});

@@ -2153,36 +2153,32 @@
 , true, 'should 
-not 
 have the primary
@@ -3995,33 +3995,39 @@
 asClass(classes.
-p
+raisedP
 rimary), true, '
@@ -4025,32 +4025,36 @@
 , true, 'should 
+not 
 have the primary
@@ -4103,33 +4103,39 @@
 asClass(classes.
-a
+raisedA
 ccent), false, '
@@ -4638,33 +4638,39 @@
 asClass(classes.
-p
+raisedP
 rimary), false, 
@@ -4747,33 +4747,39 @@
 asClass(classes.
-a
+raisedA
 ccent), true, 's

Fix unit tests to reflect className changes for less specificity