General Motors announced its plans to lay off more than 2,000 workers just hours after Donald Trump won the presidential election - putting his campaign promises to an early test.

Trump criticized the manufacturer after reports that it would shift some of its production to Mexico and vowed during his campaign to prevent layoffs in the auto industry.

But on Wednesday, the company announced that it would lay off more than 2,000 workers indefinitely at two assembly plants in Ohio and Michigan - two swings states that Trump won - starting in January.

Scroll down for video

General Motors announced its plans to lay off more than 2,000 workers just hours after Donald Trump (above, giving his victory speech) won the presidential election

The company said it will suspend the third shifts at factories in Lordstown, Ohio, near Cleveland, and in Lansing, Michigan, because customers are shifting from cars to SUVs and trucks.

About 1,250 workers will be furloughed at the Lordstown plant, which makes the Chevrolet Cruze.

US sales of the compact car through October were down 20 percent.

Another 840 will be idled at the Lansing Grand River factory.

The Lansing Grand River plant builds the Cadillac ATS and CTS, whose sales were down 17 percent through October.

GM says the moves are being made to align production to demand for the cars.

The layoffs affect plants in Ohio and Michigan, two swing states Trump won. Above, an employee on the production line at the Lansing Grand River plant in Lansing, Michigan

The automaker also announced it would invest more than $900 million at a Toledo, Ohio, transmission plant, the Lansing Grand River factory and a casting plant in Bedford, Indiana, to prepare for future new vehicles.

GM said it will invest $211 million at the Lansing plant for an unspecified 'new product program.'

The company will invest $668 million in its Toledo transmission plant for a new generation of transmissions.

In December 2014, GM said it was investing $5 billion in Mexico through 2018 - a move that would allow it to double its production capacity at its plants around the country.

In 2014, the company said the investment would create 5,600 jobs in Mexico.

About 1,250 workers will be furloughed at the Lordstown plant, which makes the Chevrolet Cruze (above, file photo)

The Detroit News reported in May that GM plans next year to move some light-duty pickup production to the Flint Assembly Plant from Mexico.

Mexican auto production has been rising in recent years as numerous automakers expand operations.

But Trump had made criticism of automakers, including General Motors and Ford, shifting jobs to Mexico a staple of his campaign speeches.

'I am fighting hard to bring jobs back to the United States,' he said in June. 'Many companies - like Ford, General Motors, Nabisco, Carrier - are moving production to Mexico.

'Drugs and illegal immigrants are also pouring across our border. This is bad for all Americans, regardless of their heritage.'

Trump has repeatedly suggesting that Ford would back down from plans to expand in Mexico or face a 35 percent tariff on vehicle exports.